package com.aaa.eat.controller;

import com.aaa.eat.pojo.vo.MealVo;
import com.aaa.eat.result.AjaxResult;
import com.aaa.eat.service.MealService;
import com.aaa.eat.util.OSSUtil;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileInputStream;
import java.io.InputStream;
import java.lang.invoke.MutableCallSite;
import java.util.UUID;

/**
 * Author:张海金
 * Description:T0D0
 * DateTime:2022/3/12 16:47
 **/
@RestController
@RequestMapping("meal")
public class MealController {

    @Autowired
    private OSSUtil ossUtil;
    @Autowired
    private MealService mealService;

    @RequestMapping("addMeal")
    public AjaxResult addMeal(MealVo mealVo, MultipartFile headImg)throws Exception{

        String path = ossUtil.uploadOSS(headImg);

        mealVo.setImgURL(path);
        System.out.println(mealVo);

        return mealService.addMeal(mealVo);
    }
}
